import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '证件编码',
    align: "center",
    dataIndex: 'number'
  },
  {
    title: '证件名称',
    align: "center",
    dataIndex: 'name'
  },
  {
    title: '证件类型',
    align: "center",
    dataIndex: 'type'
  },
  {
    title: '有效期开始时间',
    align: "center",
    dataIndex: 'startDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '有效期结束时间',
    align: "center",
    dataIndex: 'endDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '发证机构',
    align: "center",
    dataIndex: 'licenseIssuingAuthority'
  },
  {
    title: '证书描述',
    align: "center",
    dataIndex: 'description'
  },
  {
    title: '证件照',
    align: "center",
    dataIndex: 'img',
    customRender: render.renderImage,
  },
  {
    title: '状态',
    align: "center",
    dataIndex: 'status_dictText'
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "证件编码",
    field: 'number',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "证件名称",
    field: 'name',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "证件类型",
    field: 'type',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "有效期开始时间",
    field: "startDate",
    component: 'RangePicker',
    //colProps: {span: 6},
  },
  {
    label: "有效期结束时间",
    field: "endDate",
    component: 'RangePicker',
    //colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '证件编码',
    field: 'number',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入证件编码!'},
             ];
    },
  },
  {
    label: '证件名称',
    field: 'name',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入证件名称!'},
             ];
    },
  },
  {
    label: '证件类型',
    field: 'type',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入证件类型!'},
             ];
    },
  },
  {
    label: '有效期开始时间',
    field: 'startDate',
    component: 'DatePicker',
  },
  {
    label: '有效期结束时间',
    field: 'endDate',
    component: 'DatePicker',
  },
  {
    label: '发证机构',
    field: 'licenseIssuingAuthority',
    component: 'Input',
  },
  {
    label: '证书描述',
    field: 'description',
    component: 'InputTextArea',
  },
  {
    label: '证件照',
    field: 'img',
    component: 'JImageUpload',
    componentProps:{
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入证件照!'},
             ];
    },
  },
  {
    label: '状态',
    field: 'status',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "normalOrStop"
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  number: {title: '证件编码',order: 0,view: 'text', type: 'string',},
  name: {title: '证件名称',order: 1,view: 'text', type: 'string',},
  type: {title: '证件类型',order: 2,view: 'text', type: 'string',},
  startDate: {title: '有效期开始时间',order: 3,view: 'date', type: 'string',},
  endDate: {title: '有效期结束时间',order: 4,view: 'date', type: 'string',},
  licenseIssuingAuthority: {title: '发证机构',order: 5,view: 'text', type: 'string',},
  description: {title: '证书描述',order: 6,view: 'textarea', type: 'string',},
  img: {title: '证件照',order: 7,view: 'image', type: 'string',},
  status: {title: '状态',order: 8,view: 'radio', type: 'string',},
};
